<template>
    <view class="login-way">
        <view class="tab">
            <view class="tab-box">
                <view class="tab-item current">
                    <image
                        class="item-logo"
                        mode="aspectFill"
                        :src="easyGetImgUrl(tabType === 0 ? marketLogo : turntableLogo)"></image>
                    <text>活动</text>
                    <view class="bg"></view>
                </view>
                <view class="tab-item right-current">
                    <text class="statustxt">{{ item.SaleStateName }}</text>
                    <view class="bg"></view>
                </view>
            </view>
            <view class="tab-bg1" v-if="item.SaleStateName == '进行中'"></view>
            <view class="tab-bg2" v-if="item.SaleStateName == '即将开始'"></view>
            <view class="tab-bg3" v-if="item.SaleStateName == '已结束'"></view>
        </view>
        <view class="coupon-list-item">
            <view class="coupon-item" :class="{ disabled: item.SaleStateName == '已结束' }">
                <image
                    v-if="!getAppSet().isHideImg"
                    class="item-img"
                    mode="aspectFill"
                    :src="easyGetImgUrl(item.images)"></image>
                <view class="coupon-item-info">
                    <text class="coupon-name">{{ item.Name }}</text>
                    <text class="coupon-desc">{{ item.Description }}</text>
                    <text class="coupon-time"
                        >活动时间：{{ item.StartTime.split(" ")[0] }} - {{ item.EndTime.split(" ")[0] }}</text
                    >
                </view>
            </view>
            <view class="info-content" v-if="item.SaleStateName != '已结束'">
                <view class="info-header">
                    <view class="btn-box">
                        <text class="djstxt1 mr-10">距离结束</text>
                        <text class="css-djs">{{ item.Days }}</text>
                        <text class="djstxt1">天</text>
                        <text class="css-djs">{{ item.Hours }}</text>
                        <text class="djstxt1">:</text>
                        <text class="css-djs">{{ item.Minutes }}</text>
                        <text class="djstxt1">:</text>
                        <text class="css-djs">{{ item.Seconds }} </text>
                    </view>

                    <button class="btn btn-activity" @click="goDetail">进入活动</button>
                </view>
            </view>
        </view>
    </view>
</template>
<script>
import { GetNowTime } from "@/service/api/activity.js"
export default {
    props: {
        item: {
            type: Object,
            default: () => {},
        },
        tabType: {
            type: Number,
            default: 0,
        },
    },
    watch: {
        item(newVal, oldVal) {
            this.item = newVal
        },
    },
    data() {
        return {
            marketLogo: "https://hsy884.oss-cn-hangzhou.aliyuncs.com/upload/2023/04/19/20230419092203153.png", //营销logo
            turntableLogo: "https://hsy884.oss-cn-hangzhou.aliyuncs.com/upload/2023/04/19/20230419092348823.png", //转盘logo
        }
    },
    methods: {
        goDetail() {
            // this.easyGoTo("/pages_me/packet/coupon/detail?data=" + encodeURIComponent(JSON.stringify(this.item)))
            this.easyGoTo("/pages_me/packet/activity/marketDetailList")
        },
    },
}
</script>

<style lang="scss">
.login-way {
    padding: 40rpx 40rpx 0;
}

.tab {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    position: relative;
    display: flex;
    flex: 1;
    z-index: 0;

    .tab-box {
        display: flex;
        flex-direction: row;
        align-items: flex-end;
        flex: 1;
        height: 86rpx;
        perspective: 1000;
        z-index: 1;
    }

    .tab-bg1 {
        position: absolute;
        width: 100%;
        left: 0%;
        right: 2%;
        bottom: 0;
        z-index: 0;
        height: 82rpx;
        background: linear-gradient(to bottom, #f96767, #f41321);
        border-radius: 24rpx 24rpx 0 0;
    }
    .tab-bg2 {
        position: absolute;
        width: 100%;
        left: 0%;
        right: 2%;
        bottom: 0;
        z-index: 0;
        height: 82rpx;
        background: linear-gradient(to bottom, #ffcc8d, #ff983e);
        border-radius: 24rpx 24rpx 0 0;
    }
    .tab-bg3 {
        position: absolute;
        width: 100%;
        left: 0%;
        right: 2%;
        bottom: 0;
        z-index: 0;
        height: 82rpx;
        background: linear-gradient(to bottom, #e2e2e2, #b0b2b5);
        border-radius: 24rpx 24rpx 0 0;
    }

    .tab-item {
        display: flex;
        // justify-content: center;
        align-items: center;
        height: 76rpx;
        min-width: 45%;
        padding-bottom: 6rpx;
        &:first-child {
            border-radius: 24rpx 0 0 0;
        }

        &:last-child {
            border-radius: 0 24rpx 0 0;
        }
    }

    .item-logo {
        width: 56rpx;
        height: 56rpx;
        margin-left: 42rpx;
        margin-right: 12rpx;
        position: relative;
        z-index: 1;
    }

    .current {
        height: 86rpx;
        overflow: hidden;
        position: relative;
        background: rgba(0, 0, 0, 0);
        width: 150%;
        text {
            color: #6f1d16;
            font-size: 28rpx;
            font-weight: 700;
            position: relative;
            z-index: 1;
        }

        .bg {
            position: absolute;
            left: 0;
            top: 0;
            z-index: 0;
            width: 88%;
            height: 86rpx;
            /* 宽高 */
            background-color: #fff9f4;
            /* 颜色 */
            // padding: 4rpx 10rpx;
            border-radius: 24rpx 18rpx 0 0;
            box-shadow: 0px 0px 7px 0px rgba(185, 192, 208, 0.4);
            /* 设置圆角 */
            transform: perspective(12rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: 0 0;
            /* bottom left = left bottom = 0 100% 中心点偏移量*/
        }
    }
    .statustxt {
        color: #ffffff;
        font-size: 28rpx;
        margin-left: 90rpx;
        font-weight: 700;
    }
    .right-current {
        .bg {
            margin-left: 12%;
            border-radius: 18rpx 24rpx 0 0;
            // transform: perspective(5rpx) rotateX(1deg);
            /* 镜头距离元素表面的位置为8px，x轴为1.1倍y轴为1.3倍，绕x轴旋转5度 */
            transform-origin: right 0;
        }
    }
}
.coupon-list-item {
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #fff9f4, #ffffff);
    border-bottom-left-radius: 16rpx;
    border-bottom-right-radius: 16rpx;
    // margin: $app-page-padding;
    box-shadow: 0 0 20rpx #e5e5e5;
}
.coupon-item {
    display: flex;
    flex-direction: row;
    padding: $app-page-padding;

    .item-img {
        width: 210rpx;
        height: 160rpx;
        margin-right: 20rpx;
        border-radius: 8rpx;
    }

    .coupon-item-info {
        display: flex;
        flex: 1;
        flex-direction: column;
        justify-content: center;
        width: calc(100% - 320rpx);
        .coupon-name {
            font-size: $font-size-28;
            font-weight: 700;
            margin-bottom: 12rpx;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .coupon-desc {
            font-size: $font-size-24;
            margin-bottom: 12rpx;
        }
        .coupon-time {
            color: #6f1d16;
            font-size: $font-size-24;
        }
    }
}

.info-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 14rpx $app-page-padding;
    position: relative;
    text-align: left;

    .info-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10rpx;
        .btn-box {
            display: flex;
            flex-direction: row;
            flex: 1;
            align-items: center;
            .djstxt1 {
                color: $color-gray-1;
                font-size: 24rpx;
                font-weight: Medium;
            }
            .mr-10 {
                margin-right: 10rpx;
            }
            .css-djs {
                background-color: $color-gray-1;
                color: #ffffff;
                font-size: 28rpx;
                font-weight: bold;
                border-radius: 8rpx;
                padding: 5rpx 10rpx;
                margin: 0 5rpx;
            }
        }
        .btn {
            border-radius: 100rpx;
            height: 64rpx;
            width: 180rpx;
            font-size: 28rpx;
        }
    }
}
.disabled {
    opacity: 0.6;
}
</style>
